#include "common.hpp"
#include "tcpserver.hpp"
#include "dictionary.hpp"

std::string print(const std::string input)
{
    std::string output;
    std::cout << "*****" << std::endl;
    output += "*****";
    output += input;
    return output;
}

int main(int argc, char *argv[])
{
    if (argc != 2)
    {
        SerErr();
        exit(ERR_SER);
    }
    uint16_t tcp_port = std::stoi(argv[1]);

    // 1.空掉函数流程
    // Tcp_Server::TcpServer tcp_ser(tcp_port, print);

    // 2.字典
    Dictionary::Dic dic;
    dic.LoadDic();
    // auto dict_task =std::bind(dic.Translation,&dic,std::placeholders::_1);
    Tcp_Server::TcpServer tcp_ser(tcp_port, [&dic](const std::string &word) -> std::string
                                  { return dic.Translation(word); });

    tcp_ser.Init();
    tcp_ser.Run();

    return 0;
}